// forEach
function count(arr, item) {
    let ans = 0;
    arr.forEach((val) => {
        // val == item ? ans++ : 0
        (e == item) && count++;
    })
    return ans
}

//map
function count(arr, item) {
    let ans = 0
    arr.map((val) => {
        return (val === item) && ans++
    })
    return ans
}

// for
function count(arr, item) {
    let ans = 0
    for (let i = 0; i < arr.length; i++) {
        if (arr[i] === item) {
            ans++
        }
    }
    return ans
}

//filter
function count(arr, item) {
    return arr.filter((val) => {
        return val == item
    }).length;
}

//reduce
function count(arr, item) {
    return arr.reduce((prev, curr) => {
        return curr === item ? prev + 1 : prev;
    }, 0);
}

